<%--
 * (c)2010-2011 Andrea Caltroni (andrea.caltroni@pd.infn.it), INFN (www.infn.it)
 *
 * This file is part of the IGI Survey Portlet (from here on shortened to IGISP).
 * IGISP is free software: you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published by the Free 
 * Software Foundation, either version 3 of the License, or (at your option) any 
 * later version.
 *
 * IGISP is distributed in the hope that it will be useful, but WITHOUT ANY 
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with IGISP. If not, see <http://www.gnu.org/licenses/>.
 *
--%>

<%@ include file="./init.jsp" %>

<% pageContext.setAttribute("newLineChar", "\n"); %>
<% pageContext.setAttribute("newLineHtml", "<br />"); %>

<c:set var="numQuestions" value="${fn:length(survey.questions)}" />

<h3><spring:message code="survey.view.title"/></h3>

<div class="portlet-body">

	<table class="lfr-table">
		<tr>
			<th><spring:message code="survey.label.name"/>:</th>
			<td>${survey.name}</td>
		</tr>
		<tr><td colspan="2">&nbsp;</td><tr>
        <tr>
            <th><spring:message code="survey.label.description"/>:</th>
            <td><c:out value="${fn:replace(survey.description, newLineChar, newLineHtml)}" escapeXml="false" /></td>
        </tr>
        <tr><td colspan="2">&nbsp;</td><tr>
		<tr>
			<th><spring:message code="survey.label.start"/>:</th>
			<td><fmt:formatDate value="${survey.start}" dateStyle="medium" timeStyle="short" /></td>
		</tr>
        <tr>
            <th><spring:message code="survey.label.expiration"/>:</th>
            <td><fmt:formatDate value="${survey.expiration}" dateStyle="medium" timeStyle="short" /></td>
        </tr>
		<tr>
			<th><spring:message code="survey.label.status"/>:</th>
			<td>${survey.status.translatedName}</td>
		</tr>
    </table>
    
    <%--<div class="portlet-section-header"><spring:message code="survey.label.questions"/></div>--%>

    <div class="lfr-separator">&nbsp;</div>

    <div>
<c:choose><c:when test="${numQuestions <= 0}">
        <spring:message code="survey.label.noQuestions"/>.
        <a href="<portlet:renderURL><portlet:param name="action" value="showAddQuestionForm"/><portlet:param name="surveyID" value="${survey.id}"/></portlet:renderURL>"><img title="<spring:message code="question.add.button"/>" src="<html:imagesPath/>new.png" border=0 /></a>
</c:when>
<c:otherwise>
        <h4 class=""><a href="<portlet:renderURL><portlet:param name="action" value="viewSurveyQuestions"/><portlet:param name="surveyID" value="${survey.id}"/></portlet:renderURL>"><spring:message code="survey.label.questions"/> [${numQuestions}]</a></h4>
</c:otherwise></c:choose>
    </div>

</div>

<div class="lfr-separator">&nbsp;</div>

<div class="lfr-toolbar">
    <a href="<portlet:renderURL><portlet:param name="action" value="showEditSurveyForm"/><portlet:param name="surveyID" value="${survey.id}"/></portlet:renderURL>"><img title="<spring:message code="survey.edit.button"/>" src="<html:imagesPath/>edit.png" border=0 /></a>&nbsp;
    <a href="<portlet:actionURL>
                <portlet:param name="action" value="deleteSurvey"/>
                <portlet:param name="surveyID" value="${survey.id}"/>
             </portlet:actionURL>
             " onclick="return confirm('<spring:message code="message.confirm.delete.survey"/>')">
             <img title="<spring:message code="survey.delete.button"/>" src="<html:imagesPath/>delete.png" border=0 /></a>&nbsp;&nbsp;
    <a href="<portlet:renderURL portletMode="view"/>"><img title="<spring:message code="button.home"/>" src="<html:imagesPath/>home.png" border=0 /></a>
</div>
